<html>
<head><meta charset="utf-8"><title>SyncWrapper (was StaticMutex) · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html">SyncWrapper (was StaticMutex)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197783755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197783755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197783755">(May 16 2020 at 08:18)</a>:</h4>
<p>Hi everyone! I’ve been referred to this channel by <a href="https://github.com/rust-lang/rust/pull/71529#issuecomment-629211792">https://github.com/rust-lang/rust/pull/71529#issuecomment-629211792</a>: in earlier discussions in other places we came across the need to enlist the compiler’s help in proving the absence of concurrency. This works by ensuring that an object can only be accessed through exclusive references, thereby making anything that is <code>Send</code> also <code>Sync</code> (because synchronization is statically ensured).</p>
<p>In the PR above I therefore proposed StaticMutex as the name, but as <span class="user-mention" data-user-id="120791">@RalfJ</span> pointed out this has the wrong connotations. So which way do we want to go with this? <code>SyncWrapper</code> probably is the most directly linked to the intended usage, <code>Unshare</code> has been proposed as a higher-level description of the structure’s facilities. I’m fine either way, so what do you people here think?</p>



<a name="197789379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197789379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197789379">(May 16 2020 at 10:37)</a>:</h4>
<p>I think before the name bikesheding it'd better be discussed whether this is a useful addition to the standard library (or better kept as a separate crate on <a href="http://crates.io">crates.io</a>). And if it should be added, which module should it live in.<br>
Let me randomly @ a few people in case they're interested. <span class="user-mention" data-user-id="256759">@boats</span> <span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="143274">@Amanieu</span> <span class="user-mention" data-user-id="243558">@Steven Fackler</span></p>



<a name="197790530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197790530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197790530">(May 16 2020 at 11:08)</a>:</h4>
<p>I think this is sufficiently niche to be on <a href="http://crates.io">crates.io</a> rather than in libstd.</p>



<a name="197790556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197790556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197790556">(May 16 2020 at 11:09)</a>:</h4>
<p>Basically any type you would want to put in a <code>SyncWrapper</code> only has <code>&amp;mut self</code> operations. Normally this should imply that this type does not use inner mutability, which would make it implicitly <code>Sync</code>.</p>



<a name="197790774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197790774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197790774">(May 16 2020 at 11:14)</a>:</h4>
<p>also seems like there is no harm done in having this in a separate crate -- it's not like many crates need to agree on using the same type or so</p>



<a name="197790784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197790784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197790784">(May 16 2020 at 11:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="143274">Amanieu</span> <a href="#narrow/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex)/near/197790556">said</a>:</p>
<blockquote>
<p>Basically any type you would want to put in a <code>SyncWrapper</code> only has <code>&amp;mut self</code> operations. Normally this should imply that this type does not use inner mutability, which would make it implicitly <code>Sync</code>.</p>
</blockquote>
<p>you might want to "disable" the non-<code>&amp;mut</code> self methods of a type that has them.</p>



<a name="197794394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/SyncWrapper%20%28was%20StaticMutex%29/near/197794394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Roland Kuhn <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/SyncWrapper.20(was.20StaticMutex).html#197794394">(May 16 2020 at 12:53)</a>:</h4>
<p>Yes, indeed this is a good point. I’ll put it on <a href="http://crates.io">crates.io</a> then.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>